package group.program.register.phone_number;

import group.program.Controller.RegisterController;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import static org.junit.jupiter.api.Assertions.*;

class format {
    @InjectMocks
    private RegisterController registerController;

    @BeforeEach
    void setUp() {
        MockitoAnnotations.openMocks(this);
    }

    @Test
    void testValidatePhoneNumberFormat() {
        String validPhoneNumber = "12345678901";
        assertNull(registerController.validatePhoneNumberFormat(validPhoneNumber));
    }

    @Test
    void testInvalidPhoneNumberFormat1() {
        String invalidPhoneNumber = "1234567890";
        assertEquals("电话号码必须是11位的数字", registerController.validatePhoneNumberFormat(invalidPhoneNumber));
    }
    @Test
    void testInvalidPhoneNumberFormat2() {
        String invalidPhoneNumber = "123456789012";
        assertEquals("电话号码必须是11位的数字", registerController.validatePhoneNumberFormat(invalidPhoneNumber));
    }
    @Test
    void testInvalidPhoneNumberFormat3() {
        String invalidPhoneNumber = "12345abcde67890";
        assertEquals("电话号码必须是11位的数字", registerController.validatePhoneNumberFormat(invalidPhoneNumber));
    }
    @Test
    void testInvalidPhoneNumberFormat4() {
        String invalidPhoneNumber = "12345678d0";
        assertEquals("电话号码必须是11位的数字", registerController.validatePhoneNumberFormat(invalidPhoneNumber));
    }
}

